<template>
  <div>
    <router-view v-if="role == 3">
      <ship-see></ship-see>
    </router-view>
    <router-view v-else>
      <ship-edit></ship-edit>
    </router-view>
  </div>
</template>

<script>
import EventBus from "@/mitt/eventBus.js";
import rename from "@/mitt/getPath.js";
import shipSee from "./methodJustSee.vue";
import shipEdit from "./methodCanEdit.vue";
// import shipTypeCanEdit from "@/components/beAddShip/shipClient/LNG/shipTypeCanEdit.vue";

export default {
  components: {
    shipSee,
    shipEdit,
    // shipTypeCanEdit,
  },
  name: "",
  data() {
    return {
      role: null,
    };
  },

  methods: {
    handSize() {
      if (window.innerWidth > 630) {
        if (this.$store.state.width == 200) {
          this.tableWidth = (window.innerWidth - 170) * 0.985 - 20 + "px";
        } else if (this.$store.state.width == 90) {
          this.tableWidth = (window.innerWidth - 60) * 0.985 - 20 + "px";
        }
      } else {
        this.tableWidth = window.innerWidth - 30 + "px";
      }
    },
    sendMessage() {
      let res = rename();
      EventBus.emit("custom-event", res);
    },
  },
  watch: {
    "$store.state.width"(newVal, oldVal) {
      //对数据执行操作
      if (window.innerWidth > 630) {
        if (newVal == 90) {
          this.tableWidth = (window.innerWidth - 60) * 0.985 - 20 + "px";
        } else if (newVal == 200) {
          this.tableWidth = (window.innerWidth - 170) * 0.985 - 20 + "px";
        }
      }
    },
    // $route(to, from) {
    //   // 在这里根据参数的变化执行刷新页面的逻辑
    //   if (to.name == from.name) {
    //     this.close();
    //   }
    // },
  },

  created() {
    this.sendMessage();
    this.role = sessionStorage.getItem("role");
  },
  beforeMount() {
    // if (window.innerWidth > 630) {
    //   if (this.$store.state.width == 200) {
    //     this.tableWidth = (window.innerWidth - 170) * 0.985 - 20 + "px";
    //   } else if (this.$store.state.width == 90) {
    //     this.tableWidth = (window.innerWidth - 60) * 0.985 - 20 + "px";
    //   }
    // } else {
    //   this.tableWidth = window.innerWidth - 30 + "px";
    // }
  },
  mounted() {
    // let that = this;
    // this.getRenderList();
    // window.addEventListener("resize", this.handSize);
  },
  beforeUnmount() {
    // window.removeEventListener("resize", this.handSize);
  },
};
</script>
